package svg;

import java.awt.Color;
import java.awt.Font;
import java.net.URI;

public class LinkCanvas extends GObject 
{
	protected int             start;
	protected int             length;
	protected ProcessorCanvas owner;
	protected String          name;
	protected Font            titleFont = null;
	protected Color           color     = null;
	
	/* JobCanvas:
	 * start  - starting time
	 * length - the length of the job
	 * owner  - task owning the job
	 */
	public LinkCanvas(int start, int length, ProcessorCanvas owner, String name, Color color)
	{
		this.start = start;
		this.length = length;
		this.owner = owner;
		this.name = name;
		this.titleFont = new Font("SansSerif", Font.PLAIN, 14);
		this.color = color;
	}
	
	public void init(){}
	
	@Override
	public void show(URI uri) 
	{
		int height = (int)((1.0 * owner.getHeight()) / 3.0);
		int width = (int)(length * owner.getTimeUnit());
		int x = (int)(owner.getAxisStarts().getX() + start * owner.getTimeUnit());
		int y = (int)owner.getAxisStarts().getY() + 1;
		
		JobViewer.addRectangle(uri, x, y, width, height, 
				true, color, true, Color.BLACK, 1);
		// title
		JobViewer.writeText(uri, name, x + owner.getGap(), y + height / 2 + titleFont.getSize() / 2, titleFont, Color.BLACK);
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}
}
